package com.xja.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xja.entity.PageBean;
import org.apache.dubbo.config.annotation.Service;
import javax.annotation.Resource;
import com.xja.entity.Food;
import com.xja.mapper.FoodMapper;
import com.xja.service.FoodService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author 周广瑞
 * @date  2022/4/14 9:56
 * 
 */
@Service
public class FoodServiceImpl implements FoodService{
    private Logger logger = LoggerFactory.getLogger(FoodServiceImpl.class);

    @Resource
    private FoodMapper foodMapper;

    @Override
    public PageBean<Food> selectByFind(Integer npage) {
        PageHelper.startPage(npage,3);
        Page<Food> adminPage = (Page<Food>) foodMapper.selectFoodList();

        PageBean<Food> adminPageBean = new PageBean<>();
        adminPageBean.setContentList(adminPage.getResult());
        adminPageBean.setNpage(npage);
        adminPageBean.setPageCount(adminPage.getPages());
        adminPageBean.setTotals(adminPage.getTotal());
        return adminPageBean;
    }

    @Override
    public int deleteByPrimaryKey(Integer foodId) {
        return foodMapper.deleteByPrimaryKey(foodId);
    }

    @Override
    public int insert(Food record) {
        return foodMapper.insert(record);
    }

    @Override
    public int insertSelective(Food record) {
        return foodMapper.insertSelective(record);
    }

    @Override
    public Food selectByPrimaryKey(Integer foodId) {
        return foodMapper.selectByPrimaryKey(foodId);
    }

    @Override
    public int updateByPrimaryKeySelective(Food record) {
        return foodMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Food record) {
        return foodMapper.updateByPrimaryKey(record);
    }

}
